package com.zx.notification.admin.controller;

import com.zx.core.wrapper.ObjectWrapper;
import com.zx.core.wrapper.PageWrapper;
import com.zx.notification.admin.service.INotificationPushTasksService;
import com.zx.notification.common.param.NotificationPushTasksParam;
import com.zx.notification.common.vo.NotificationPushTasksVO;
import com.zx.validation.annotation.ParameterValidation;
import com.zx.validation.annotation.ParameterValidations;
import com.zx.validation.enums.ValidateRulesEnum;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * description: 推送任务管理控制器 <br>
 * create: 2025-10-17
 * </p>
 *
 * @author zhou  xun
 */
@RestController
@RequestMapping("/notification-push-tasks")
@RequiredArgsConstructor
public class NotificationPushTasksController {

    private final INotificationPushTasksService iNotificationPushTasksService;

    /**
     * 分页查询推送任务列表
     *
     * @param notificationPushTasksParam 查询参数
     * @return 推送任务列表
     */
    @PostMapping("/list")
    @PreAuthorize("hasAuthority('notify:task:list')")
    @ParameterValidations({
            @ParameterValidation(index = 0, desc = "推送任务参数", rules = {ValidateRulesEnum.OBJECT}, groups = {com.zx.validation.groups.Query.class})
    })
    public PageWrapper<NotificationPushTasksVO> list(@RequestBody NotificationPushTasksParam notificationPushTasksParam) {
        return iNotificationPushTasksService.getNotificationPushTasksVOListByPage(notificationPushTasksParam);
    }

    /**
     * 获取指定推送任务信息
     *
     * @param notificationPushTaskId 推送任务Id
     * @return 推送任务信息
     */
    @GetMapping("/info/{notificationPushTaskId}")
    @PreAuthorize("hasAuthority('notify:task:detail')")
    @ParameterValidations({
            @ParameterValidation(index = 0, desc = "推送任务Id", rules = {ValidateRulesEnum.NOT_NULL})
    })
    public ObjectWrapper<NotificationPushTasksVO> getNotificationPushTaskInfo(@PathVariable("notificationPushTaskId") String notificationPushTaskId) {
        return iNotificationPushTasksService.selectNotificationPushTaskById(notificationPushTaskId);
    }
}